package com.outsider.pipeline;

import java.util.ArrayList;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.outsider.dao.MovieMapper;
import com.outsider.entity.Movie;

import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.pipeline.Pipeline;

public class DyttPipeline implements Pipeline{
    
	
	public void process(ResultItems resultItems, Task task) {
		    @SuppressWarnings("resource")
			ApplicationContext ac =new ClassPathXmlApplicationContext("classpath:spring-mybatis.xml");
		    MovieMapper movieMapper=ac.getBean(MovieMapper.class);
            Movie movie=new Movie();
            movie.setTitle(resultItems.get("title").toString());
            movie.setUrl(resultItems.get("url").toString());
            movieMapper.insert(movie);
		    
		
		}
		

}
